﻿using System;
using System.Collections.Generic;
using System.Data;
using System.Linq;
using System.Text;
using Gao.Poker.Domain;

namespace Gao.Poker.Services
{
    public class BuyRecordService : BaseService
    {

        private static BuyRecordService _instance;

        public static BuyRecordService Instance()
        {
            return _instance ?? (_instance = new BuyRecordService());
        }

        public void Save(BuyRecord buyRecord)
        {
            if (buyRecord == null) return;
            
            if(buyRecord.ID == 0)
            {
                DbContext.BuyRecords.Add(buyRecord);
            }
            else
            {
                DbContext.BuyRecords.Attach(buyRecord);
                DbContext.Entry(buyRecord).State = EntityState.Modified;
            }

            DbContext.SaveChanges();
        }
    }
}
